//关键词检索
import {isFileExists } from "@/api/book";
export const regKeyWord = (value) =>{
  var reg = /^[^~?!@#$%^&*'"<>,.；]+$/;
  if (value != "" && !reg.test(value)) {
      return false;
  }
  else {
      return true;
  }
}

export function getsrcpre(item) {
  let aa = new Array();
  var src=window.SITE_CONFIG.imgUrl;
  var filename=item.filename;
  var imgname=filename.slice(0, filename.lastIndexOf("."))+'.png';
  var fileextension=filename.slice(filename.lastIndexOf('.') + 1);
  
  if(filename.indexOf("0497")>=0)
  {
    src=src+"/0497/"+imgname
  }
  else if(fileextension=="teb"){
    src=src+"/teb/"+imgname
  }
  else{
    src=src+imgname;
  }
  aa.push(src)
  return aa
};
export function getimg(item){

  var src=window.SITE_CONFIG.imgUrl;
  var filename=item.filename;
  var imgname=filename.slice(0, filename.lastIndexOf("."))+'.png';
  var fileextension=filename.slice(filename.lastIndexOf('.') + 1);
  
  if(filename.indexOf("0497")>=0)
  {
    src=src+"/0497/"+imgname
  }
  else if(fileextension=="teb"){
    src=src+"/teb/"+imgname
  }
  else{
    src=src+imgname;
  }
  return src
};

 export async function   isFileExist(filename){
     
  var    {data} =  await  isFileExists({filename:filename})

  return  data;
  }
